#!/bin/bash
#description backup mysql
DATE="`date +%F`"
BAKCPDIR="/data/backup/`date +%F`"
MYSQLDB="$*"
MYSQLUSER="backup"
MYSQLPW="Aa$0611fi"
if [ $UID -ne 0 ];then
	echo "this scripts must be user the root user"
	sleep 2
	exit 2
fi
#Define Dir and mkdir dir
if [ ! -d $BACKUPDIR ];then
	mkdir -p $BACKUPDIR
fi
#use mysqldump backup mysql
/usr/local/mysql/bin/mysqldump -u$MYSQLUSER -pMYSQLPW -d $MYSQLDB >$BACKUPDIR/webapp_${DATE}.sql
if [ $? -eq 0 ];then
	echo "the mysql backup successfully"
else
	echo "the mysql backup failed"
fi
